home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / qbtools1.arc / AEGETFIL.BAS < prev    next >
BASIC Source File  |  1987-01-17  |  2KB  |  77 lines

  1. rem $linesize:132
  2. rem $title:'Application Engineer Standard Routines'
  3. rem $subtitle:'Get all file names matching wildcards'
  4. '                Include the COMMON values
  5. rem $include:'AESHARED.BAS'            
  6. '     Changed to ensure that no *garbage* is returned
  7.  
  8. sub getfiles(fl$(1),flnm$,ext$,count%) static
  9.  
  10.     dim inreg%(8),outreg%(8)            ' registers for dos calls
  11.     fl%=0%                              ' initial file count
  12.     axreg%=0%                           ' as suggested by the ms people ...
  13.     bxreg%=1%
  14.     cxreg%=2%
  15.     dxreg%=3%
  16.     bpreg%=4%
  17.     sireg%=5%
  18.     direg%=6%
  19.     flreg%=7%
  20.  
  21.     dta$=string$(256,0)
  22.     fcb$=string$(44,0)         ' extended file control block
  23.  
  24.     inreg%( axreg% )=&h1a00
  25.     inreg%( dxreg% )=sadd(dta$)
  26.     call int86(&h21, varptr(inreg%(0)) , varptr(outreg%(0)) )   ' set dta
  27.  
  28.     mid$(fcb$,1,1)=chr$(&hff)
  29.     mid$(fcb$,7,1)=chr$(0)
  30.     mid$(fcb$,9,8)=flnm$+string$(8-len(flnm$),"?")
  31.     mid$(fcb$,17,3)=ext$+string$(3-len(ext$),"?")
  32.  
  33.     inreg%( axreg% )=&h1100           ' get first match
  34.     inreg%( dxreg% )=sadd(fcb$)
  35.  
  36.     call int86(&h21 , varptr(inreg%(0)) , varptr(outreg%(0)) )
  37.  
  38.     p1$=mid$(dta$,9,8)
  39.     p2$=mid$(dta$,17,3)
  40.     call ctrl.trim(p1$)
  41.     call ctrl.trim(p2$)
  42.     if len(p2$) then p2$="."+p2$
  43.     fl$=p1$+p2$
  44.  
  45.  
  46.     tp$=""
  47.  
  48.     while tp$<>fl$
  49.  
  50.         fl%=fl%+1%
  51.         if fl%>ubound(fl$,1) then
  52.             call ae.error("Error in getfiles sub program : too many files")
  53.             end
  54.         end if
  55.         fl$(fl%)=fl$
  56.         tp$=fl$
  57.         inreg%( axreg% )=&h1a00
  58.         inreg%( dxreg% )=sadd(dta$)
  59.         call int86(&h21, varptr(inreg%(0)) , varptr(outreg%(0)) )   ' set dta
  60.  
  61.         inreg%( axreg% )=&h1200
  62.         inreg%( dxreg% )=sadd(fcb$)
  63.         call int86(&h21 , varptr(inreg%(0)) , varptr(outreg%(0)) )
  64.  
  65.         p1$=mid$(dta$,9,8)
  66.         p2$=mid$(dta$,17,3)
  67.         call trim(p1$)
  68.         call trim(p2$)
  69.         if len(p2$) then p2$="."+p2$
  70.         fl$=p1$+p2$
  71.     wend
  72.     if fl$(fl%)="" then
  73.         fl%=fl%-1%
  74.     end if
  75.     count%=fl%
  76. end sub
  77.